import requests

from api.get_token import get_token


class DepManage:
    @staticmethod
    def dep_query(headers, dep_id):
        response = requests.get(f"http://ihrm2-test.itheima.net/api/company/department/{dep_id}", headers=headers)
        return response

    @staticmethod
    def dep_add(headers, req_json):
        response = requests.post(f"http://ihrm2-test.itheima.net/api/company/department", headers=headers, json=req_json)
        return response

    @staticmethod
    def dep_modify(headers, req_json):
        response = requests.put(f"http://ihrm2-test.itheima.net/api/company/department/1527276461776523264", headers=headers, json=req_json)
        return response

    @staticmethod
    def dep_delete(headers, dep_id):
        response = requests.delete(f"http://ihrm2-test.itheima.net/api/company/department/{dep_id}", headers=headers)
        return response


if __name__ == '__main__':
    dm = DepManage()
    token1 = {"Authorization": get_token()}
    res = dm.dep_query(token1, "1527199758962216960").json()
    # print(res)

    res = dm.dep_delete(token1, "1527085546235580416").json()
    print(res)


